let nColumns = this._colLimit ? Math.min(this._colLimit,
nChildren)
: nChildren;
- let totalSpacing = Math.max(0, nColumns - 1) * this._spacing;
+ let totalSpacing = Math.max(0, nColumns - 1) * this._getSpacing();
// Kind of a lie, but not really an issue right now. If
// we wanted to support some sort of hidden/overflow that would
// need higher level design
return;
let children = this._getVisibleChildren();
- let nColumns, spacing;
- if (forWidth < 0) {
+ let nColumns;
+ if (forWidth < 0)
nColumns = children.length;
- spacing = this._spacing;
- } else {
- [nColumns, , spacing] = this._computeLayout(forWidth);
- }
+ else
+ [nColumns, ] = this._computeLayout(forWidth);
let nRows;
if (nColumns > 0)
nRows = 0;
if (this._rowLimit)
nRows = Math.min(nRows, this._rowLimit);
- let totalSpacing = Math.max(0, nRows - 1) * spacing;
+ let totalSpacing = Math.max(0, nRows - 1) * this._getSpacing();
let height = nRows * this._vItemSize + totalSpacing;
alloc.min_size = height;
alloc.natural_size = height;
let children = this._getVisibleChildren();
let availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1;
-
- let [nColumns, usedWidth, spacing] = this._computeLayout(availWidth);
+ this.updateSpacingForSize(availWidth);
+ let spacing = this._getSpacing();
+ let [nColumns, usedWidth] = this._computeLayout(availWidth);
let leftPadding;
switch(this._xAlign) {
_computeLayout: function (forWidth) {
let nColumns = 0;
let usedWidth = 0;
- let spacing = this._spacing;
-
- if (this._colLimit) {
- let itemWidth = this._hItemSize * this._colLimit;
- let emptyArea = forWidth - itemWidth;
- spacing = Math.max(this._spacing, emptyArea / (2 * this._colLimit));
- spacing = Math.round(spacing);
- }
+ let spacing = this._getSpacing();
while ((this._colLimit == null || nColumns < this._colLimit) &&
(usedWidth + this._hItemSize <= forWidth)) {
if (nColumns > 0)
usedWidth -= spacing;
- return [nColumns, usedWidth, spacing];
+ return [nColumns, usedWidth];
},
_onStyleChanged: function() {
visibleItemsCount: function() {
return this._grid.get_n_children() - this._grid.get_n_skip_paint();
+ },
+
+ setSpacing: function(spacing) {
+ this._fixedSpacing = spacing;
+ },
+
+ _getSpacing: function() {
+ return this._fixedSpacing ? this._fixedSpacing : this._spacing;
+ },
+
+ updateSpacingForSize: function(availWidth) {
+ let spacing = this._spacing;
+
+ if (this._colLimit) {
+ let itemWidth = this._hItemSize * this._colLimit;
+ let emptyArea = availWidth - itemWidth;
+ spacing = Math.max(spacing, emptyArea / (2 * this._colLimit));
+ spacing = Math.round(spacing);
+ }
+ this.setSpacing(spacing);
}
});